FLAGS=-g

EXECUTABLE := schedule_sim script_gen

#cpp files that include a main function (based on executable names)
MAIN_SOURCE := $(addprefix src/,$(addsuffix .cpp, $(EXECUTABLE)))

#get all the cpp files that don't include a main function
SOURCE := $(wildcard src/*.cpp)
SOURCE := $(filter-out $(MAIN_SOURCE),$(SOURCE))
OBJECTS := $(addprefix obj/,$(notdir $(SOURCE:.cpp=.o)))

all: $(EXECUTABLE)

script_gen: obj/script_gen.o
	g++ $(FLAGS) $^ -o $@

#link .o's to binary
schedule_sim: $(OBJECTS) obj/schedule_sim.o
	g++ $(FLAGS) $^ -o $@

#compile all .cpp to .o (two rules for whether or not the cpp has a matching .h)
obj/%o: src/%cpp src/%h src/Process.h
	g++ $(FLAGS) -c -o $@ $<
obj/%o: src/%cpp
	g++ $(FLAGS) -c -o $@ $<

clean:
	rm -f $(EXECUTABLE) obj/*
